package com.ycp.erp.main.activity;

import android.text.TextUtils;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jakewharton.rxbinding2.view.RxView;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.utils.Toaster;
import com.one.common.view.base.BaseActivity;
import com.one.common.view.widget.ClearEditView;
import com.one.common.view.widget.MyTitleBar;
import com.ycp.erp.R;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import io.reactivex.disposables.Disposable;

/**
 * Class Des:修改密码
 * Created by bjh on 2021/9/3.
 */
@Route(path = RouterPath.MODIFY_PSW)
public class ModifyPswActivity extends BaseActivity {
    @BindView(R.id.ctOldPsw)
    ClearEditView ctOldPsw;
    @BindView(R.id.rlSelectWareHouse)
    RelativeLayout rlSelectWareHouse;
    @BindView(R.id.ctNewPsw)
    ClearEditView ctNewPsw;
    @BindView(R.id.ctNewPswAgain)
    ClearEditView ctNewPswAgain;
    @BindView(R.id.tvSubmit)
    TextView tvSubmit;

    @Override
    protected void initPresenter() {

    }

    @Override
    public void initView() {
        super.initView();
        Disposable subscribe = RxView.clicks(tvSubmit).throttleFirst(500, TimeUnit.MILLISECONDS).subscribe(o -> {
            if (TextUtils.isEmpty(ctOldPsw.getText())||TextUtils.isEmpty(ctNewPsw.getText())||TextUtils.isEmpty(ctNewPswAgain.getText())){
                Toaster.showShortToast("请填写密码信息");
                return;
            }
            if (!ctNewPsw.getText().equals(ctNewPswAgain.getText())){
                Toaster.showShortToast("两次新密码不相同");
                return;
            }
        });
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_modify_psw;
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("修改密码").hideLine();
    }
}
